Skip to content

Implement Azure AD OIDC role-based authorization#3

Merged
kolosovpetro merged 3 commits intomainfrom
oidc
Apr 9, 2023
Merged

Implement Azure AD OIDC role-based authorization#3
kolosovpetro merged 3 commits intomainfrom
oidc

Conversation

@kolosovpetro
Copy link
Contributor

Closes: #1

@kolosovpetro kolosovpetro requested review from Khachatur-Khachatryan and ketteiteki and removed request for ketteiteki April 5, 2023 19:58
}

[Authorize(Roles = "User, Admin")]
[HttpGet("user_and_admin")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use "-" symbol instead of underscore

IdentityModelEventSource.ShowPII = true;

app.UseSwagger();
app.UseSwaggerUI();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Swagger UI config. For example:

app.UseSwaggerUI(c =>
{
    c.SwaggerEndpoint("/swagger/v1/swagger.json", "Event Triangle Consumer API V1");
});

Don't forget about SwaggerGen configureation. For example:

builder.Services.AddSwaggerGen(c =>
{
    c.SwaggerDoc("v1",
        new OpenApiInfo { Title = "Event Triangle Consumer API", Version = "v1" });
});



app.UseSwagger();
app.UseSwaggerUI();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Swagger UI config. For example:

app.UseSwaggerUI(c =>
{
    c.SwaggerEndpoint("/swagger/v1/swagger.json", "Event Triangle Sender API V1");
});

Don't forget about SwaggerGen configureation. For example:

builder.Services.AddSwaggerGen(c =>
{
    c.SwaggerDoc("v1",
        new OpenApiInfo { Title = "Event Triangle Sender API", Version = "v1" });
});

[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
[Authorize(Roles = "User, Admin")]
[HttpGet("user_and_admin")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use "-" symbol instead of underscore

public IEnumerable<WeatherForecast> Get()
[Authorize(Roles = "User, Admin")]
[HttpGet("user_and_admin")]
public IEnumerable<WeatherForecast> GetForUserAndAdmin()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to project package Swashbuckle.AspnetCore.Annotations and add [SwaggerOperation] attribute to controler methods

public IEnumerable<WeatherForecast> Get()
[Authorize(Roles = "Admin")]
[HttpGet("admin")]
public IEnumerable<WeatherForecast> GetForAdmin()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to project package Swashbuckle.AspnetCore.Annotations and add [SwaggerOperation] attribute to controler methods

@kolosovpetro
Copy link
Contributor Author

We need to consider the auth flow as https://security.stackexchange.com/a/130478

@kolosovpetro kolosovpetro merged commit 9d59480 into main Apr 9, 2023
@kolosovpetro kolosovpetro deleted the oidc branch April 15, 2023 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement OIDC authorization

3 participants